﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using So.ContribReViews.UserReviewedItems.Models;
using Orchard.ContentManagement.Drivers;
using So.ContribReviews.UserReviewedItems.ViewModels;
using Orchard.ContentManagement;
using Orchard.Users.Models;
using JetBrains.Annotations;

namespace So.ContribReViews.UserReviewedItems.Drivers
{
    [UsedImplicitly]
    public class UserReviewedItemsPartDriver : ContentPartDriver<UserReviewedItemsPart>
    {
        private readonly IUserReviewedItemsService _userReviewedItemsService;
        private const string TemplateName = "Parts/UserReviewedItemsPart";

        public UserReviewedItemsPartDriver(IUserReviewedItemsService UserReviewedItemsService)
        {
            _userReviewedItemsService = UserReviewedItemsService;
        }

        protected override DriverResult Display(UserReviewedItemsPart part, string displayType, dynamic shapeHelper)
        {
            var model = _userReviewedItemsService.GetUserReviewedItems(part.Id);
            return ContentShape("Parts_UserReviewedItemsPart", () => shapeHelper.Parts_UserReviewedItemsPart(ContentPart: part, ViewModel: model));
        }
    }
}
